package com.panda.pandawash.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.panda.pandawash.R;
import com.panda.pandawash.view.StatusBarCompat;

import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

/**
 * Created by gaowf on 2017/2/10.
 */

public class SafeBoxActivity extends Activity {
    @ViewInject(R.id.btn_safe_box_return)
    private ImageView imageView;

    @ViewInject(R.id.safe_box_cost_set)
    private TextView setCostTV;

    @ViewInject(R.id.safe_box_report_form)
    private TextView reportFormTV;

    @ViewInject(R.id.safe_box_modify_psd_safe_box)
    private TextView modifyPSDTV;

    @ViewInject(R.id.safe_box_exit_safe_box)
    private TextView exitSafeTV;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_safe_box);
        x.view().inject(this);

        if(Build.VERSION.SDK_INT>= Build.VERSION_CODES.KITKAT) {
            StatusBarCompat.compat(this, getResources().getColor(R.color.colorPrimary));
        }

        setCostTV.setOnClickListener(mOnClickListener);
        reportFormTV.setOnClickListener(mOnClickListener);
        modifyPSDTV.setOnClickListener(mOnClickListener);
        exitSafeTV.setOnClickListener(mOnClickListener);
    }


    private View.OnClickListener mOnClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch(view.getId()) {
                case R.id.safe_box_cost_set:
                    Intent intent_cost_set = new Intent(SafeBoxActivity.this, CostSetActivity.class);
                    startActivity(intent_cost_set);
                    break;
                case R.id.safe_box_report_form:
                    Intent intent_report_form = new Intent(SafeBoxActivity.this, ReportFormActivity.class);
                    startActivity(intent_report_form);
                    break;
                case R.id.safe_box_modify_psd_safe_box:
                    Intent intent_modify_psd = new Intent(SafeBoxActivity.this, ModifySafePsdActivity.class);
                    startActivity(intent_modify_psd);
                    break;
                case R.id.safe_box_exit_safe_box:
                    onExitNavigationView();
                    break;
            }
        }
    };

    @Event(R.id.btn_safe_box_return)
    private void excuteReturn(View v) {
        finish();
    }

    private void onExitNavigationView() {
        new AlertDialog.Builder(this).setTitle("确认退出吗？")
                .setCancelable(false)
                .setIcon(android.R.drawable.ic_dialog_info)
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        SafeBoxActivity.this.finish();
                    }
                })
                .setNegativeButton("返回", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // 点击“返回”后的操作,这里不设置没有任何操作
                    }
                }).show();
    }

}
